
CC=gcc
TARGET_NAME=test_main.out



SRCS += $(wildcard *.c)
OBJS = $(SRCS:.c=.o)

CFLAGS += -I./ctest_log/

LDFLAGS += -Llib/
LDLIBS += -lctest_log

SUBDIRS += ctest_log

$(info INFO:CC=${CC} CFLAGS=${CFLAGS} LDFLAGS=${LDFLAGS} OBJS=${OBJS})

.PHONY: clean subdirs ${SUBDIRS}
.c.o:
	$(CC) -c $(CFLAGS) -o $@ $^

${TARGET_NAME}: ${OBJS}
	for dir in ${SUBDIRS}; do \
		$(MAKE) -C $$dir; \
	done
	${CC} ${LDFLAGS} ${LDLIBS} -o $@ $^

clean:
	rm -f ${OBJS}
	rm -f ${TARGET_NAME}
	rm -f lib/*
	for dir in ${SUBDIRS}; do \
		$(MAKE) clean -C $$dir; \
	done
